package com.aramis.mydytt.ui.bean

import java.io.Serializable

/**
 * Description: dytt_beans
 * @author lizhidan
 * Created: 2021/5/11
 */

data class SearchResultBean(val total: Int, val rows: List<MovieShortInfoBean>) : Serializable

data class MovieShortInfoBean(val id: Int, val categoryId: Int, val name: String, val publishTime: String) : Serializable

data class DyttMovieDetailBean(
    val id: Int, val categoryId: Int, val content: String?, val downloadUrl: String?,
    val homePicUrl: String?, val name: String, val publishTime: String?
) : Serializable {

    fun toMovieDetailDownListBeanList(cate: Int): List<MovieDetailDownListBean> {
        return if (cate == MovieField.CATE_SERIES && downloadUrl != null && downloadUrl.contains(";")) {
            return downloadUrl.split(";").filter { it.isNotBlank() }.map {
                val title = if (it.contains("]")) {
                    it.substring(it.lastIndexOf(']') + 1, it.lastIndexOf('.'))
                } else {
                    it.substring(it.lastIndexOf('/') + 1, it.lastIndexOf('.'))
                }
                MovieDetailDownListBean(id, title, it, fromDytt = true)
            }
        } else {
            listOf(MovieDetailDownListBean(id, name, downloadUrl, fromDytt = true))
        }
    }
}